require(['../config/requireconfig'],function(config){
	//根据需要添加
	require(['jquery','common/pccommons','common/banner','common/marque'],function($,com,banner,marque,productLogic){

        com.init({headerPos:{cur:"index"}, lazyHeader:true});
        com.header();

		var pageLogic = new PageLogic($,com,banner,productLogic);
		pageLogic.init();

	});
});

var PageLogic = function($,com,banner,productLogic){
	
	return {
		init:function(){
			var _this = this;
			_this.banner();
			//_this.laodActivity(_this);
			//_this.laodNotice(_this);
			_this.bindEvents();
		},
		banner:function(){
			// com.ajax({
			// 	url:'/pc/home/banners.ahtml',
			// 	type:'get',
			// 	data:{"systemDiv":18 , "type" :2 ,  "bannerArea":2}, 
			// 	success:function(data){
			// 		var array=new Array(); 
			// 		$(data.data).each(function(idx,ban){
			// 			var map = {} 		 			 
			// 			map.imgPath = ban.imageUrl;  
			// 			map.url = ban.url;
			// 			array.push(map);
			// 	 	});
			// 		banner.init({
			// 			container:$(".banner"),
			// 			data:array
			// 		});
			// 	}
			// });
			var data = {
				"indexBanner":{
					"code":"SUCCESS",
					"message":"处理成功(SUCCESS)",
					"data":[
							{"imgPath":"../../frontlib/img/banner/banner2.jpg","url":"https://www.baidu.com"},
					]
				}
			};
			banner.init({
				container:$(".banner"),
				data:data.indexBanner.data
			});
		},
		//平台公告
		laodNotice:function(_this){
			com.ajax({
				url:'/pc/notice/notice.ahtml',//获取金票理财首页公告
				type:'get',
				data:{"systemDiv":2 , "type" :5 ,  "pageIndex":1,  "pageSize":10}, 
				success:function(data){
					var noticeList =data.data.list; 
					if (noticeList.length > 0) {
						var datas = noticeList;
				 		var noticeContentleft = "";
						var noticeContentright = "";

				 		if(noticeList.length <= 5){
							for(var i=0; i<noticeList.length; i++){
								noticeContentleft += "<a class='notice-li' href='#'><span class='left'>"+datas[i].notice.title+"</span><span class='right'>"+com.utils().str2Date(datas[i].notice.createTimeStr).pattern("yyyy-MM-dd")+"</span></a>";
							}
						}
						else {
							for(var i=0; i<5; i++){
								noticeContentleft += "<a class='notice-li' href='#'><span class='left'>"+datas[i].notice.title+"</span><span class='right'>"+com.utils().str2Date(datas[i].notice.createTimeStr).pattern("yyyy-MM-dd")+"</span></a>";
							}
							
							for(var i=5; i<noticeList.length; i++){
								noticeContentright += "<a class='notice-li' href='#'><span class='left'>"+datas[i].notice.title+"</span><span class='right'>"+com.utils().str2Date(datas[i].notice.createTimeStr).pattern("yyyy-MM-dd")+"</span></a>";
							}
						}
						
						$("#notice-left").html(noticeContentleft);
						$("#notice-right").html(noticeContentright);
					}	
					//跑马灯
					var data=new Array(); 
					$(noticeList).each(function(idx,announ){
			 			var map ={}
			 			map.title=announ.notice.title;
			 			data.push(map);
				 	});
					$("#marqueMsgs").marque({data},
					function(data){
						return '<a href="#">'+ data.title +'</a>'; 
					});
				}
			});
		},
		//活动专区
		laodActivity:function(_this){
			com.ajax({
				url:'/pc/activity/activities.ahtml',//获取金票管家活动
				type:'get',
				data:{"systemDiv":2 , "platformType" :5 ,  "pageIndex":1,  "pageSize":10},
				success:function(data){
					var activityList =data.data.list; 
					if (activityList.length > 0) {
						_this.activityIcon(activityList); 
					}		
				}
			});
		},
		bindEvents:function(){
			var _this = this;
		},
	}
}
